<template>
  <div>
    <img class="logo" src="/static/img/down.png" alt="">
    <p>请前往蜂巢影视联盟APP </p>
    <p>继续为您支持的主播投票</p>
    <div @click="downLoadApp" class="btn">立即前往</div>
  </div>
</template>

<script>
import { Toast } from 'vant';
export default {
  name: 'download',
  data() {
    return {
      env: '',
      iosUrl: 'https://apps.apple.com/cn/app/%E8%9C%82%E5%B7%A2%E5%BD%B1%E8%A7%86%E8%81%94%E7%9B%9F/id1568825575?l=en',
      androidUrl: 'https://a.app.qq.com/o/simple.jsp?pkgname=com.lucky.luckyclient',
    }
  },
  created() {
    this.$emit('footer', false);
    this.getNowEnv()
  },
  methods: {
    //根据环境下载或者唤醒
    downLoadApp() {
      let _this = this
       Toast('准备下载')
      //浏览器
      if (this.env == 1) {
        window.location.href = 'android://com.lc.caixuyingshi/home'
        setTimeout(function () {
          let hidden = window.document.hidden || window.document.mozHidden || window.document.msHidden || window.document.webkitHidden
          if (typeof hidden == "undefined" || hidden == false) {
            window.location.href = _this.androidUrl
          }
        }, 1500);
      } else if (this.env == 2) {
        window.location.href = 'https://81beea3ae2d151792195f3859d3d968b.share2dlink.com/'
        // window.location.href = 'ShanXiAppcaixuyingshi://'
        // setTimeout(function () {
        //   let hidden = window.document.hidden || window.document.mozHidden || window.document.msHidden || window.document.webkitHidden
        //   if (typeof hidden == "undefined" || hidden == false) {
        //     window.location.href = _this.iosUrl
        //   }
        // }, 1500);
      }
    },
    //判断环境
    getNowEnv() {
      //判断环境
      let u = navigator.userAgent,
        isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1,//android终端
        isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),//ios
        isWx = !!u.match(/MicroMessenger/i);//微信
      if (isWx) {
        Toast('微信')
        this.isWx = true
      }
      if (isAndroid) {
        Toast('安卓')
        this.env = 1
      }
      if (isiOS) {
        Toast('苹果')
        this.env = 2
      }
    }
  },
  mounted() {

  }

}
</script>

<style  scoped>
.logo {
  display: block;
  width: 85%;
  margin: 150px auto 20px;
}
p {
  color: #fff;
  font-size: 20px;
  text-align: center;
  margin-bottom: 5px;
}
.btn {
  width: 85%;
  margin-top: 50px;
  background: #fc6e20;
  border-radius: 61px;
  line-height: 36px;
  font-size: 18px;
  text-align: center;
  color: #fff;
}
</style>